package cn.sycoder.mapper;

import cn.sycoder.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.Date;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author 杨润发
 * @since 2024-10-15
 */
@Repository
public interface UserMapper extends BaseMapper<User> {

    // 自定义sql
    @Update("update user set dept_id = #{deptId},dept_name = #{deptName} where user_id = #{userId}")
    int updateByUserId(Long userId, Long deptId, String deptName);

    // 查询用户所属的角色id
    @Select("select role_id from user where user_name = #{username}")
    Long selectRoleId(String username);

    /*// 用户信息添加
    @Insert("insert into user(user_name, user_password, user_real_name, role_id, role_name, user_mobile, user_email, user_sex, add_time) values (#{userName}, #{userPassWord}, #{userRealName}, #{roleId}, #{roleName}, #{userMobile}, #{userEmail}, #{userSex}, #{addTime}")
    int save(String userName,
             String userPassWord,
             String userRealName,
             Long roleId,
             String roleName,
             String userMobile,
             String userEmail,
             String userSex,
             Date addTime);*/

    /*@Update("update user set user_id = #{userId},user_name = #{userName},user_real_name = #{userRealName}, " +
            "role_id = #{roleId},role_name = #{roleName},user_mobile = #{userMobile},user_email = #{userEmail}," +
            "user_sex = #{userSex},edit_time = #{editTime}")
    int updateByUserId(Long userId,
                       String userName,
                       String userRealName,
                       Long roleId,
                       String roleName,
                       String userMobile,
                       String userEmail,
                       String userSex,
                       Date editTime);*/

}
